/*
*Copyright 2021-2023 NERCIS
*
*Licensed under the Apache License, Version 2.0 (the "License");
*you may not use this file except in compliance with the License.
*You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*Unless required by applicable law or agreed to in writing, software
*distributed under the License is distributed on an "AS IS" BASIS,
*WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*See the License for the specific language governing permissions and
*limitations under the License.
*/

package cn.ac.nercis.pes.model.dto.evaluation.asset;

import cn.ac.nercis.pes.model.base.AssetField;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;

/**
 * 密码产品系统资产信息
 * @author zpy
 * @version 1.0.0
 */
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class PwdProductDTO implements AssetField {
    /**
     * ID
     */
    private String id;
    /**
     * 产品名称
     */
    private String name;
    /**
     * 生产厂商
     */
    private String vendor;
    /**
     * 商密型号
     */
    private String model;
    /**
     * 使用的密码算法
     */
    private String algorithm;
    /**
     * 数量
     */
    private String count;
    /**
     * 用途
     */
    private String use;
    /**
     * 是否测评
     */
    private Boolean isUse;
    /**
     * 备注
     */
    private String desc;

    /**
     * 引用资产Id
     */
    private String quoteAssetId;

    /**
     * 设置字段对应内容
     * @param fieldName 字段名
     * @param value 值内容
     */
    @Override
    public void setField(String fieldName,String value){
        switch (fieldName){
            case "name":
                name = value;
                break;
            case "vendor":
                vendor = value;
                break;
            case "model":
                model = value;
                break;
            case "algorithm":
                algorithm = value;
                break;
            case "count":
                count = value;
                break;
            case "use":
                use = value;
                break;
            default:
                break;
        }
    }

    /**
     * 获取字段对应内容
     * @param fieldName 字段名
     */
    @Override
    public String getField(String fieldName){
        return switch (fieldName) {
            case "name" -> name;
            case "vendor" -> vendor;
            case "model" -> model;
            case "algorithm" -> algorithm;
            case "count" -> count;
            case "use" -> use;
            default -> StringUtils.EMPTY;
        };
    }

}